package com.safety51.bootstrap.demo.application.service;

import com.safety51.bootstrap.commons.event.DomainEventPublisher;
import com.safety51.bootstrap.demo.application.events.AsyncExampleEvent;
import com.safety51.bootstrap.demo.application.events.PingEvent;
import org.springframework.stereotype.Service;

/**
 * Created by liuyuancheng on 2021/9/29  <br/>
 *
 * @author liuyuancheng
 */
@Service
public class DomainEventExampleService {

    public void diPublish(String pong) {
        // 同步阻塞的任务
        DomainEventPublisher.publish(new PingEvent(this, pong));
        // 异步非阻塞的任务，看具体Listener的区别
        DomainEventPublisher.publish(new AsyncExampleEvent(this, pong + "-async"));
    }

}
